class Node:
    def __init__(self,value,next=None):
        self.value = value
        self.next = next


def createLink(): # 创建链表
    head = Node(0)
    p = head
    for i in range(1,11):
        p.next = Node(i) # 连接
        p = p.next # 移动
    return head

def insertLink(x,head): # 插入x元素
    p = Node(x)
    p.next = head.next # 连接
    head.next = p # 连接
    return head

def deleteLink(x,head): # 删除x元素
    p1 = p2 = head # p1:后指针 p2: 前指针
    while p1 != None:
        if p1.value == x:
            p2.next = p1.next
        p2 = p1
        p1 = p1.next
    return head

def showLink(head):
    p = head.next
    while p!= None:
        print(p.value,end=" ")
        p = p.next
    print("")


if __name__ == '__main__':
    head = createLink()
    n = int(input())
    for i in range(n):
        x = int(input())
        deleteLink(x,head)
        insertLink(x,head)
        showLink(head)

# 本代码主要参考蓝桥杯省赛14天夺奖冲刺营